package com.cpp.dao;

import com.cpp.bean.Tbl_Sina_Dzh;
import com.cpp.db.DBUtils;


/**
 * A data access object (DAO) providing persistence and search support for
 * TblSinaDzh entities. Transaction control of the save(), update() and delete()
 * operations can directly support Spring container-managed transactions or they
 * can be augmented to handle user-managed Spring transactions. Each of these
 * methods provides additional information for how to configure it for the
 * desired type of transaction control.
 * 
 * @see com.cpp.bean.Tbl_Sina_Dzh
 * @author MyEclipse Persistence Tools
 */

public class Tbl_Sina_Dzh_DAO {
	

	public void saveOrUpdata(Tbl_Sina_Dzh dzh) {
		String sql = "insert into tbl_sina_dzh(uid,screenName,createdAt,sid,mid,text,source_url,source_name,favorited,truncated," +
				"inReplyToStatusId,inReplyToUserId,inReplyToScreenName,thumbnailPic,bmiddlePic,originalPic,retweetedStatus,geo,latitude," +
				"longitude,repostsCount,commentsCount,annotations,type,level) values(?,?,?,?,?,?,?,?,?,?" +
				",?,?,?,?,?,?,?,?,?" +
				",?,?,?,?,?,?)";
		Object[] params = new Object[]{dzh.getUid(),dzh.getScreenName(),dzh.getCreatedAt(),dzh.getSid(),dzh.getMid(),dzh.getText(),dzh.getSourceUrl(),dzh.getSourceName(),dzh.getFavorited(),dzh.getTruncated()
				,dzh.getInReplyToStatusId(),dzh.getInReplyToUserId(),dzh.getInReplyToScreenName(),dzh.getThumbnailPic(),dzh.getBmiddlePic(),dzh.getOriginalPic(),dzh.getRetweetedStatus(),dzh.getGeo(),dzh.getLatitude()
				,dzh.getLongitude(),dzh.getRepostsCount(),dzh.getCommentsCount(),dzh.getAnnotations(),dzh.getType(),dzh.getLevel()
							};
		try {
			DBUtils.update(sql, params);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
	
	public int queryId(String sid){
		String sql = "select id from tbl_sina_dzh where sid = '"+sid+"'";
		try {
			return DBUtils.queryInt(sql);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return 0;
		}
	}

	
}